
#include <stdio.h>
#include <string.h>
#include "iostream"
#include "f_func.h"

using namespace std;

int main(int argc, char* argv[])
{
	
	const char* _f_ = "build";
	FILE* config = NULL; 
	FILE* block = NULL;
	
	int block_size = 0;
	int	block_num = 0;
	int raid_type = -1;
	int disk_num = 0;
	int i,type;
	string file_name;
	char file_num[10];
	char* zeros;
	char argvchar[2];
	if(argc<5){
#ifdef PRINT_MSG
	printf("[%s]: use %s N K M L \n",_f_,_f_); 
#endif
	return 1;
	}

	if(sscanf(argv[1],"%d",&disk_num)==0) return -1;
	if(sscanf(argv[2],"%d",&block_num)==0) return -1;
	if(sscanf(argv[3],"%d",&block_size)==0) return -1;
	///!!!!!!!!!!!! raid 01 10
	if(sscanf(argv[4],"%c%c",&argvchar[0],&argvchar[1])==2)
	{
		if(argvchar[0]=='0'&&argvchar[1]=='1')
		raid_type =11;
		else if(argvchar[0]=='1'&&argvchar[1]=='0')
		raid_type =10;
		else
		{
		#ifdef PRINT_MSG
			printf("[%s]: can't define RAID type %s \n",_f_,argv[4]); 
		#endif
			return -1;
		}
	}
	else if(sscanf(argv[4],"%d",&raid_type)==0) return -1;

	if( build_raid(raid_type, disk_num,block_num,block_size))
		return 0;
	else
		return -1;
	
}

